package es.mfp.practicos.dao;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.ehcache.annotations.Cacheable;
import com.googlecode.ehcache.annotations.TriggersRemove;
import com.googlecode.ehcache.annotations.When;

import es.mfp.practicos.domain.Parametros;

@Repository
public class ParametrosDAOImpl extends GenericDaoImpl<Parametros, Long> implements ParametrosDAO {

	@Override
	@Transactional(readOnly = false)
	@TriggersRemove(cacheName = { "parametrosCache" }, when = When.BEFORE_METHOD_INVOCATION, removeAll = true)
	public void insert(Parametros t) {
		super.insert(t);
	}

	@Override
	@Transactional(readOnly = false)
	@TriggersRemove(cacheName = { "parametrosCache" }, when = When.BEFORE_METHOD_INVOCATION, removeAll = true)
	public void remove(Parametros t) {
		super.remove(t);
	}

	@Override
	@Transactional(readOnly = false)
	@TriggersRemove(cacheName = { "parametrosCache" }, when = When.BEFORE_METHOD_INVOCATION, removeAll = true)
	public void update(Parametros object) {
		super.update(object);
	}

	@SuppressWarnings("unchecked")
	@Override
	@Cacheable(cacheName = "parametrosCache")
	public List<Parametros> getAll() {
		List<Parametros> entities = null;

		String s = "SELECT c FROM " + Parametros.class.getSimpleName() + " c ORDER BY c.id DESC";
		entities = getJpaTemplate().find(s);

		return entities;
	}

}
